package urnav.example.com;

import urnav.example.com.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;



public class QAlter extends Activity{
	
	String TAG = "URNav";
	
	public void onCreate(Bundle savedInstanceState){
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.qalter);
//		Bundle extras = getIntent().getExtras();
//		String name = extras.getString("name");
	
		
    
    final TextView myText;
    myText = (TextView)findViewById(R.id.textView1);
    myText.setText("Ihr Alter: ");

    final Button closeButton;
     closeButton = (Button)findViewById(R.id.button1);
     closeButton.setText("OK");
     
     final EditText edittext = (EditText) findViewById(R.id.editText1);
     edittext.setOnKeyListener(new OnKeyListener() {
         public boolean onKey(View v, int keyCode, KeyEvent event) {
             // If the event is a key-down event on the "enter" button
             if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                 (keyCode == KeyEvent.KEYCODE_ENTER)) {
               // Perform action on key press
               Log.i(TAG, "From form: " + edittext.getText());
               return true;
             }
             return false;
         }
     });
     
     closeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
//        	Log.i(TAG, "XFZ");
        	
        	Intent resultIntent = new Intent();
        	String alter= edittext.getText().toString();
        	resultIntent.putExtra("Alter", alter);
        	
        	Log.i(TAG, "putextra: " + resultIntent.getStringExtra("Alter"));
        	
        	if (!(alter.equals(""))) {
        	setResult(RESULT_OK, resultIntent);
        	finish();
        	}
        } });

}
	
	
	protected void onDestroy(){


		super.onDestroy();
		
	}
	
	protected void onResume(){

		
	super.onResume();
	}
	protected void onPause(){

		super.onPause();
		
	}
}